package demo5;

import net.sf.cglib.proxy.Enhancer;

import java.lang.reflect.Proxy;

public class CglibProxyFactory {

    private static CglibInterceptor callback = new CglibInterceptor();
    public  static <T> T create(Class<T> target){

       /* (T) Proxy.newProxyInstance(target.getClass().getClassLoader()
                ,target.getClass().getInterfaces()
                ,handler
        );*/
        Enhancer enhancer =new Enhancer();
        enhancer.setCallback(callback);
        enhancer.setSuperclass(target);
        return (T) enhancer.create();

    }

}
